package com.example.designpattenexample.state.example;

public class TV {
    private Channel currentChannel;

    private void setChannel(Channel channel){
        this.currentChannel = channel;
    }

    public void displayCCTV(int no) throws Exception {
        this.setChannel(getChannel(no));
        this.currentChannel.broadCast();
    }

    private Channel getChannel(int no) throws Exception {
        Channel channel  = (Channel) Class.forName("com.example.designpattenexample.state.example.CCTV"+no).newInstance();
        return channel;
    }



}
